import { Modal } from "antd";

import DynamicQueryTable, { SelectionType } from "@/components/report/DynamicQueryTable";
import { useState } from "react";
import type { MesProcess } from "@/pages/mes/process/entity";

interface MultiProcessSelectorProps {
	open: boolean;
	onCancel: () => void;
	onOk: (selectedProcesss: MesProcess[]) => void;
}

const MultiProcessSelector:React.FC<MultiProcessSelectorProps> = ({ open, onCancel, onOk }) => {
  
  // 选中的物料
  const [selectedProcessList, setSelectedProcessList] = useState<MesProcess[]>([]);

  const handleOk = () => {
		onOk(selectedProcessList);
	};

	return (
		<Modal title="选择工序" open={open} onCancel={onCancel} onOk={handleOk} width={800} destroyOnClose>
			<DynamicQueryTable 
        reportCode="process_selector" 
        selectionType={SelectionType.CHECKBOX}
        onSelectChange={(selectedRows) => {setSelectedProcessList(selectedRows)}}  
      />
		</Modal>
	);
}

export default MultiProcessSelector;